package com.bt.lms.dao.servise.impl;

import com.bt.lms.entity.StuStatusBasicInfo;
import com.bt.lms.dao.servise.StuStatusBasicInfoDao;
import com.bt.lms.utils.DriverUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.LocalDate;

/**
 * 学籍基本信息实现dao
 */
public class StuStatusBasicInfoDaoImpl implements StuStatusBasicInfoDao {
    @Override
    public boolean update(String sql, StuStatusBasicInfo stuStatusBasicInfo,Long id) throws SQLException {
        String stuNo = stuStatusBasicInfo.getStuNo();
        String name = stuStatusBasicInfo.getName();
        Integer iDType = stuStatusBasicInfo.getiDType();
        String iDCard = stuStatusBasicInfo.getiDCard();
        LocalDate enterSchoolTime = stuStatusBasicInfo.getEnterSchoolTime();
        String lengthOfSchooling = stuStatusBasicInfo.getLengthOfSchooling();
        String className = stuStatusBasicInfo.getClassName();
        String enrollPlan = stuStatusBasicInfo.getEnrollPlan();
        String learningCenter = stuStatusBasicInfo.getLearningCenter();
        String specialty = stuStatusBasicInfo.getSpecialty();
        Integer currentState = stuStatusBasicInfo.getCurrentState();
        //获取连接
        Connection conn = DriverUtils.Driver();
        //获取执行对象
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setString(1,stuNo);
        ps.setString(2,name);
        ps.setInt(3,iDType);
        ps.setString(4,iDCard);
        ps.setString(5, String.valueOf(enterSchoolTime));
        ps.setString(6,lengthOfSchooling);
        ps.setString(7,className);
        ps.setString(8,enrollPlan);
        ps.setString(9,learningCenter);
        ps.setInt(10,currentState);
        ps.setString(11,specialty);
        ps.setLong(12,id);


        int i = ps.executeUpdate();

        //关闭资源
        ps.close();
        conn.close();

        return true;
    }
}
